﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CERT.Services.DAL;

namespace CERT.Services
{
    public partial class NETServices
    {
        public IEnumerable<LookupType> GetAllLookupTypes()
        {
            using (var context = new NETEntities())
            {
                return context.LookupTypes.AsEnumerable<LookupType>();

            }

        }

        public LookupType GetSingleLookupType(System.Linq.Expressions.Expression<Func<LookupType, bool>> predicate)
        {
            using (var context = new NETEntities())
            {
                return context.Set<LookupType>().FirstOrDefault<LookupType>(predicate);

            }
        }

        public void DeleteLookupType(int id)
        {
            using (var context = new NETEntities())
            {
                var entity = context.Set<LookupType>().FirstOrDefault(a => a.LookupTypeID == id);
                context.Set<LookupType>().Remove(entity);
                context.SaveChanges();
            }

        }

        public void UpdateLookupType(LookupType entity)
        {
            using (var context = new NETEntities())
            {
                context.Entry<LookupType>(entity).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }

        }

        public void AddLookupType(LookupType entity)
        {
            using (var context = new NETEntities())
            {
                context.Set<LookupType>().Add(entity);
                context.SaveChanges();
            }

        }
    }
}